#ifndef SKVIEW_H
#define SKVIEW_H

#include <QGraphicsView>
#include <QtGui/QLineEdit>
#include <QtGui/QTableView>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QPushButton>
#include <QtGui/QScrollBar>

#include "../SketchModelWrapper.h"
#include "skscene.h"
#include "common/constraint/GeometricConstraintType.h"
class SkView : public QGraphicsView
{
    Q_OBJECT

    SkScene *scene;
    SketchModelWrapper* sketchModel;

    QLineEdit* k;
    QLineEdit* l;
    QLineEdit* m;
    QLineEdit* n;
    QPushButton *clearButton;

    QPlainTextEdit *console;

    QTableView* tableConstraint;
    QTableView* tablePrimitive;
    QTableView* tableParemeter;
    common::GeometricConstraintType constraintState;

    SkScene* getSkScene();
public:
    SkView(QWidget * parent=0); //const int& width, const int& height,

    ~SkView();

    void setContainers(QLineEdit* k,QLineEdit* l,QLineEdit* m,QLineEdit* n);
    void setTables(QTableView* tableConstraint,QTableView* tablePrimitive,QTableView* tableParemeter);
    void setConsole(QPlainTextEdit *console);
    void setClearButton(QPushButton *pushButtonClear);
    int getPointK();
    int getPointL();
    int getPointM();
    int getPointN();

    void consoleStart(QString txt);
    void consoleEnd(QString txt);
    void populateScene();

signals:
    void setPointId(int);
    void pointPosHasChanged(int,QPointF);

public slots:
	void deletePrimitive();
	void deleteConstraint();
	void addConstraint();
    void resetTables();

    void pointPosChanged(int i,QPointF newPos);
    void pointClicked(int i);
    void solve();
    void relax();
    void drawLine();
    void drawSegment();
    void drawCircle();

    void viewChanged();
	void tablePrimitiveChanged();
	void tableConstraintChanged();
	void tableParameterChanged();

protected:
    void drawBackground(QPainter *painter, const QRectF &rect);
    void keyPressEvent(QKeyEvent *event);
    void wheelEvent(QWheelEvent *event);
    void scaleView(qreal scaleFactor);
};

#endif // SKVIEW_H
